/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						       popup_window.h

	$Header: /game/popup_window.h $

	$NoKeywords: $

 ************************************************************************/

#ifndef POPUP_WINDOW_H_INCLUDED
#define POPUP_WINDOW_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "game_window.h"
// ---------------------------------------------------------------------------
// window which closes if any click occurs outside the window
// ---------------------------------------------------------------------------

class t_popup_window : public t_window
{
public:
	typedef void ( t_window::* t_mouse_function )( t_mouse_event const& event );

	t_popup_window( t_screen_point point, t_window* parent = 0 );
	t_popup_window( t_screen_rect const& rect, t_window* parent = 0 );

    virtual void left_button_down( t_mouse_event const& event );
    virtual void left_button_up( t_mouse_event const& event );
	virtual void left_double_click( t_mouse_event const& event );
	virtual void mouse_move( t_mouse_event const& event );
	virtual void on_close();
    virtual void right_button_down( t_mouse_event const& event );
    virtual void right_button_up( t_mouse_event const& event );
	virtual void right_double_click( t_mouse_event const& event );
	virtual void update_size();  // update size based on child windows

protected:
	t_popup_window(  t_transparency transparency, t_window* parent );

	virtual void  add_child( t_window* window ); // add a child window
	virtual bool  children_handle_mouse();
	void          pass_event( t_mouse_function function, t_mouse_event const& event,
		                      bool check_close, bool forward_after_close );

	bool         m_passing_event;
	t_window_ptr m_last_mouse_window;
};

#endif // POPUP_WINDOW_H_INCLUDED